/*
 *  $Id: TurnsAdvert.cs 951 2009-12-05 18:17:59Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008-2009 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

using AgateLib.Geometry;

namespace Ragima {
    public class TurnsAdvert {
        private const int AdvertTime = 100;

        private UI.Sprite _sprite;
        private Point _p1, _p2;
        private int _s1, _s2, _time;

        public TurnsAdvert() {
            _sprite = Data.TurnsAdvert.GetSprite("adverts");
            int x = (Constants.DisplayWidth - _sprite.Descriptor.Size.Width) / 2;
            int h = _sprite.Descriptor.Size.Height;
            int y = (Constants.DisplayHeight - 2*h) / 2;
            _p1 = new Point(x, y);
            _p2 = new Point(x, y+h);
            _time = 0;
        }

        public void SetAdvert(bool self, bool offence) {
            if (self) {
                _s1 = 1;
                _s2 = offence ? 5 : 4;
            } else {
                _s1 = 0;
                _s2 = offence ? 3 : 2;
            }
            _time = AdvertTime;
        }

        public void Draw() {
            if (_time == 0) return;
            _sprite.Draw(_s1, _p1);
            _sprite.Draw(_s2, _p2);
        }

        public void Process() {
            if (_time > 0) _time--;
        }
    }
}
